<div xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ice="http://www.icesoft.com/icefaces/component">
	<f:loadBundle
	basename="eu.smoothit.sis.admin.util.msg_bundle" var="msgBundle" /> 
<ice:dataTable id="tableMonitoring"
	binding="#{monitoringViewBean.dataTable}"
	value="#{monitoringViewBean.dataList}" var="dataItem"
	rendered="#{!empty monitoringViewBean.dataList}" >
	<f:facet name="header">
		<ice:outputText value="Monitoring View" />
	</f:facet>
	<ice:column>
		<f:facet name="header">
			<ice:panelGroup>
				<ice:commandLink actionListener="#{monitoringViewBean.actionSort}"
					title="Sort on ID">
					<f:attribute name="sortField" value="swarm.id" />
					<ice:outputText value="Swarm ID" />
				</ice:commandLink>
				<ice:outputText value="&#0160;&#9650;" escape="false"
					rendered="#{monitoringViewBean.sortField == 'id' &amp;&amp; !monitoringViewBean.sortAscending}" />
				<ice:outputText value="&#0160;&#9660;" escape="false"
					rendered="#{monitoringViewBean.sortField == 'swarmId' &amp;&amp; monitoringViewBean.sortAscending}" />
			</ice:panelGroup>
		</f:facet>
		<ice:outputText value="#{dataItem.swarm.id}" />
	</ice:column>


	<ice:column>
		<f:facet name="header">
			<ice:panelGroup>
				<ice:commandLink actionListener="#{monitoringViewBean.actionSort}"
					title="Sort on swarm.torrentHash">
					<f:attribute name="sortField" value="swarm.torrentHash" />
					<ice:outputText value="TorrentHash/FileName" />
				</ice:commandLink>
			</ice:panelGroup>
		</f:facet>
		<ice:outputText value="#{dataItem.swarm.torrentHash}" />
	</ice:column>

	<ice:column>
		<f:facet name="header">
			<ice:panelGroup>
				<ice:commandLink actionListener="#{monitoringViewBean.actionSort}"
					title="Sort on downloadRatePerSwarm">
					<f:attribute name="sortField" value="downloadRatePerSwarm" />
					<ice:outputText value="Total Download Rate" />
				</ice:commandLink>
			</ice:panelGroup>
		</f:facet>
		<ice:outputText value="#{dataItem.downloadRatePerSwarm}" />
	</ice:column>
	<ice:column>
		<f:facet name="header">
			<ice:panelGroup>
				<ice:commandLink actionListener="#{monitoringViewBean.actionSort}"
					title="Sort on NrOfAssociatedLocalPeers">
					<f:attribute name="sortField" value="nrOfAssociatedLocalPeers" />
					<ice:outputText value="No. Of AssociatedLocal Peers" />
				</ice:commandLink>
			</ice:panelGroup>
		</f:facet>
		<ice:outputText value="#{dataItem.nrOfAssociatedLocalPeers}" />
	</ice:column>

	<ice:column>
		<f:facet name="header">
			<ice:panelGroup>
				<ice:commandLink actionListener="#{monitoringViewBean.actionSort}"
					title="Sort on NrOfAssociatedIoP">
					<f:attribute name="sortField" value="noOfAssociatedIop" />
					<ice:outputText value="No. Of Associated IoP" />
				</ice:commandLink>
			</ice:panelGroup>
		</f:facet>
		<ice:outputText value="#{dataItem.nrOfAssociatedIop}" />
	</ice:column>

	<ice:column>
		<f:facet name="header">
			<ice:panelGroup>
				<ice:commandLink actionListener="#{monitoringViewBean.actionSort}"
					title="AssociatedIoP">
					<f:attribute name="sortField" value="nrOfAssociatedIop" />
					<ice:outputText value="Details" />
				</ice:commandLink>
			</ice:panelGroup>
		</f:facet>
		<ice:commandButton value="Show"
			action="#{monitoringViewBean.showDetails}" rendered="#{!monitoringViewBean.showDetailsTag}"/>
		<ice:commandButton value="Hidden"
			action="#{monitoringViewBean.hideDetails}"  rendered="#{monitoringViewBean.showDetailsTag  &amp;&amp; monitoringViewBean.editModeRow}"/>

	</ice:column>

	<f:facet name="footer">
		<ice:panelGrid columns="4">

			<ice:panelGroup>
				<ice:inputText value="#{monitoringViewBean.dataTable.rows}"
					label="#{msgBundle.labelRowsPage}"  size="1">
					<f:validateLongRange minimum="1" maximum="100" />
				</ice:inputText>
				<ice:commandButton value="#{msgBundle.buttonSet}"
					action="#{monitoringViewBean.pageFirst}"  />
			</ice:panelGroup>
			<ice:outputText value="#{msgBundle.labelPaging}:" />
			<ice:panelGroup>
				<ice:commandButton value="#{msgBundle.buttonFirst}"
					action="#{monitoringViewBean.pageFirst}" 
					disabled="#{monitoringViewBean.dataTable.first == 0}" />
				<ice:commandButton value="#{msgBundle.buttonPrevious}"
					action="#{monitoringViewBean.pagePrevious}" 
					disabled="#{monitoringViewBean.dataTable.first == 0}" />
				<ice:commandButton value="#{msgBundle.buttonNext}"
					action="#{monitoringViewBean.pageNext}" 
					disabled="#{monitoringViewBean.dataTable.first + monitoringViewBean.dataTable.rows >= monitoringViewBean.dataTable.rowCount}" />
				<ice:commandButton value="#{msgBundle.buttonLast}"
					action="#{monitoringViewBean.pageLast}" 
					disabled="#{monitoringViewBean.dataTable.first + monitoringViewBean.dataTable.rows >= monitoringViewBean.dataTable.rowCount}" />
				<ice:outputText
					value="#{msgBundle.labelPage}: #{monitoringViewBean.currentPage} / #{monitoringViewBean.totalPages}" />
			</ice:panelGroup>
			<ice:panelGroup>
				<ice:commandButton value="#{msgBundle.buttonRefresh}"
					action="#{monitoringViewBean.actionRefresh}" immediate="true"
					 />

			</ice:panelGroup>
		</ice:panelGrid>
	</f:facet>
</ice:dataTable> 
 <ice:panelGroup
	rendered="#{empty monitoringViewBean.dataList &amp;&amp; !monitoringViewBean.message}">
	<ice:panelGroup rendered="#{!monitoringViewBean.searchMode}">
		<ice:outputText value="#{msgBundle.textNoData}" />
	</ice:panelGroup>
	<ice:outputText value="#{msgBundle.textRefineSearch}"
		rendered="#{monitoringViewBean.searchMode}" />
	<ice:commandButton value="#{msgBundle.buttonReset}"
		action="#{monitoringViewBean.actionRefresh}"  />
</ice:panelGroup> <ice:panelGroup rendered="#{monitoringViewBean.showDetailsTag}">
	
<ice:outputLabel value="For Swarm ID#{monitoringViewBean.selectedSwarm.id}"/>
	<ice:dataTable value="#{monitoringViewBean.associatedLocaPeers}" var="local">
	<f:facet name="header">
	<ice:outputText value="Associated Local Peers" />
	</f:facet>
		<ice:column>
		<f:facet name="header">
	<ice:outputText value="ID" />
	</f:facet>
			<ice:outputText value="id#{local.id} " />
		</ice:column>
				<ice:column>
				<f:facet name="header">
	<ice:outputText value="Up Rate" />
	</f:facet>
				<ice:outputText value="N/A" rendered="#{local.up_rate==null}" />
			<ice:outputText value="#{local.up_rate} " rendered="#{local.up_rate!=null}"/>
		</ice:column>
				<ice:column>
				<f:facet name="header">
	<ice:outputText value="Down Rate" />
	</f:facet>
				<ice:outputText value="N/A" rendered="#{local.down_rate==null}" />
			<ice:outputText value="#{local.down_rate}" rendered="#{local.down_rate!=null}" />
		</ice:column>
	</ice:dataTable>
	<br/>
	<ice:dataTable value="#{monitoringViewBean.associatedIoPs}" var="iop">
	<f:facet name="header">
	<ice:outputText value="Associated IoPs" />
	</f:facet>
		<ice:column>
		<f:facet name="header">
	<ice:outputText value="ID" />
	</f:facet>
			<ice:outputText value="id#{iop.id} " />
		</ice:column>
		<ice:column>
		<f:facet name="header">
	<ice:outputText value="Up Rate" />
	</f:facet>
		<ice:outputText value="N/A" rendered="#{iop.up_rate==null}" />
			<ice:outputText value="#{iop.up_rate} " rendered="#{iop.up_rate!=null}"/>
		</ice:column>
				<ice:column>
				<f:facet name="header">
	<ice:outputText value="Down Rate" />
	</f:facet>
				<ice:outputText value="N/A" rendered="#{iop.down_rate==null}" />
			<ice:outputText value="#{iop.down_rate} " rendered="#{iop.down_rate!=null}"/>
		</ice:column>
	</ice:dataTable>
</ice:panelGroup>

</div>
